Now let's work on our buy button so that we can actually purchase things from our shop.
So I am in the shop script.
The shop script is on the shop frame.
The shop frames in the screen do.
So in my shop script.
I'm going to scroll up to the top.
I'm going to get two variables.
I'm going to get one local player equals, I'm going to get one for the player game, get service players
and I'll do a dot logo player.
I need the player because I need to check to see if he has enough money or she has enough money before
we do the purchasing of the server side.
And I also need the buy button buy button that is on my shop frame.
Underneath the shop brain, we have our two buy frame.
Underneath the two buy frame, we have our buy button.
So when someone presses the buy button, let's go down here.
We'll get our buy button dot activated, connect that to a function and we need to check to see if there's
something in the preview frame.
Right.
So we'll do it if preview name dot text.
And I'm just going to check the name because we update the name and the price at the same time.
So I'm going to check to see if it's not equal to an empty string because I'm going to clear out the
strings with nothing is selected.
If you put like nothing selected, you'll have to account for that.
So if player dot leader stats, dot points, dot value is greater than or equal to well, we're going
to check the preview price, but that's text.
So we're going to need to do this two number conversion.
Then we'll do preview price dot text then.
So we're just changing the text and the preview price to a number.
And then this is a number, right?
This is an int value.
All right, let's do our shop.
Ari So the the we have enough points to buy the thing.
The thing was selected.
We're going to fire the server, fire to the server and say, Hey, buy this.
So I'm going to say preview name, dot, text.
And now this is a little bit dangerous.
A lot of security people are going to are going to get a little bit excited.
But we we can we can fix this easily.
I'm actually going to pass the price right price dot text.
We could do the checks on the other side if we get time.
I'm not really that concerned.
But what could happen is somebody because this is going to be client code, somebody could put a very
large negative number in here sending it to the server.
And now your leader stats is like 10 million and you get the gun, right?
So we should we should account for that.
It's rare, but if you get a big game, someone, someone's going to figure it out.
So if something was not or something was not selected.
So if this failed, then we did not have something select Oh, I'm sorry, this one is going to be.
We did not have enough money.
So here's my ls for this f let's.
I'm the only thing I'm going to do.
And else for this one, it'll just pass through if you don't have anything selected.
So do I.
Not enough money.
All right.
We could do a printout.
Let's do a printout.
Just check.
Make sure it's working.
So I'll do a print.
We don't have anything catching that server event, so we don't have to worry about buying anything
right now.
Let's say buying dot, dot, dot.
Even though we don't have to worry about it, we're willing to admit it.
Passing the name dot text.
Cool.
Let's try it.
Play.
And as my little bell.
Dang.
Oh, we got to look at our output window.
Looking good.
No errors.
That's a little scrunched up here.
We could work on that if we want to do a famous lemon by it.
Buying famous lemon.
So our money is sufficient because I have like 2000 points now.
And we're not subtracting because we're not actually buying them.
But that's all right.
We'll go ahead and do that.
If we move this in.
Oh, yeah, that works.
Oh, that's because I have my image based on the aspect ratio is cuing off of the width.
So if I do it this way, I'm all right.
I think I'm going to stay with that, though, because if you're on a phone, it's more likely the width
is going to actually mess you up.
All right.
Let's go ahead and do the server side now to complete the purchase.